//
//  YYT_CommentTableViewCell.m
//  AudioVisualFeast
//
//  Created by 张琪 on 16/1/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "QL_CommentTableViewCell.h"
#import <UIImageView+WebCache.h>

@interface QL_CommentTableViewCell ()
@property (nonatomic, retain) UIImageView *imageview;
@property (nonatomic, retain) UILabel *name;
@property (nonatomic, retain) UILabel *comments;
@property (nonatomic, retain) UILabel *time;
@property (nonatomic, retain) UIButton *dianzan;

@end
@implementation QL_CommentTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.dianzan = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.dianzan addTarget:self action:@selector(buttonDidPress) forControlEvents:UIControlEventTouchUpInside];
        [self.dianzan setImage:[UIImage imageNamed:@"dianzan"] forState:UIControlStateNormal];
        [self addSubview:self.dianzan];
        
        self.imageview = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:self.imageview];
        _imageview.contentMode = UIViewContentModeScaleAspectFill;
        self.imageview.clipsToBounds = YES;
        self.imageview.layer.cornerRadius = 16;
        
        
        self.name = [[UILabel alloc] initWithFrame:CGRectZero];
        self.name.font = [UIFont systemFontOfSize:13];
        self.name.textColor = [UIColor whiteColor];
        [self addSubview:self.name];
        
        
        self.comments = [[UILabel alloc] initWithFrame:CGRectZero];
        self.comments.font = [UIFont systemFontOfSize:14];
        self.comments.textColor = [UIColor whiteColor];
        self.comments.numberOfLines = 0;
        [self addSubview:self.comments];
        
        
        self.time = [[UILabel alloc] initWithFrame:CGRectZero];
        self.time.font = [UIFont systemFontOfSize:13];
        self.time.textColor = [UIColor whiteColor];
        [self addSubview:self.time];
        
        
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    self.imageview.frame = CGRectMake(10, 10, 32, 32);
    self.name.frame = CGRectMake(50, 20, 250, 13);
    self.comments.frame = CGRectMake(15, 40, self.bounds.size.width - 30, 50);
    self.time.frame = CGRectMake(15, 20 + 70, 250, 13);
    self.dianzan.frame = CGRectMake(340, 80, 30, 30);
    
}
-(void)setModel:(QL_MVCommentModel *)model {
    _model = model;
    [self.imageview sd_setImageWithURL:[NSURL URLWithString:_model.userHeadImg]];
    self.name.text = _model.userName;
    self.comments.text = _model.content;
    self.time.text = _model.dateCreated;
    
}

- (void)buttonDidPress{
    [self.dianzan setImage:[UIImage imageNamed:@"dianjizan"] forState:UIControlStateNormal];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
